package com.tre.jdevtemplateboot.web.interceptor;


import com.tre.jdevtemplateboot.common.constant.SysConstantToken;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *  @author Jdev
 */

@Component
public class OptionInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response,
                             Object handler) {
        if (SysConstantToken.HTTP_REQUEST_METHOD_OPTIONS.equals(request.getMethod())) {
            response.setStatus(HttpServletResponse.SC_OK);
        }
        return true;
    }

}
